﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;

namespace AuctionHouseDataLibrary
{
    public class ItemDatabaseContext :DbContext
    {
        public ItemDatabaseContext()
            : base("ItemDB")
        {
            Database.SetInitializer<ItemDatabaseContext>(new ItemInitializer());
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
            modelBuilder.Entity<AuctionCurrentPrice>()
                .HasKey(c => new { c.AuctionId, c.ScanEventId });
        }

        public DbSet<Item> Items { get; set; }
        public DbSet<ScanEvent> ScanEvents { get; set; }
        public DbSet<Auction> Auctions { get; set; }
        public DbSet<AuctionCurrentPrice> AuctionCurrentPrices { get; set; }
        public DbSet<RecurringAHScan> RecurringAHScans { get; set; }
    }
}